﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using DocumentFormat.OpenXml.Packaging;

namespace Exentials.Xoox.Spreadsheet
{
    public class XSheet : XElementBase, ISequence
    {
        private XAttributeBase<string> _sheetName;
        private XAttributeBase<int> _sheetId;
        private XAttributeBase<string> _relId;
        private XWorksheet _worksheet;

        internal XSheet(string name, int index, string relationId, XWorksheet worksheet)
            : base("sheet")
        {
            _sheetName = new XAttributeBase<string>(this, "name");
            _sheetId = new XAttributeBase<int>(this, "sheetId");
            _relId = new XAttributeBase<string>(this, SpreadsheetSchemas.Relationships + "id");

            _sheetName.Value = name;
            _sheetId.Value = index;
            _relId.Value = relationId;
            _worksheet = worksheet;
        }

        public string Name
        {
            get { return _sheetName.Value; }
            set { _sheetName.Value = value; }
        }

        public int Index
        {
            get { return _sheetId.Value; }
        }

        public XWorksheet WorkSheet
        {
            get { return _worksheet; }
        }
    }
}